<?php
header("Content-type: text/html; charset=utf-8");
require("inc/common.inc.php");
if(empty($_COOKIE['userid']) || $_COOKIE['userid']=="" || empty($_COOKIE['username']) || $_COOKIE['username']==""){
	echo "<script>window.parent.location='/user/Login.php';</script>";
	exit();
}else{
	$mxuserid = $_COOKIE['userid'];
	$mxusername = $_COOKIE['username'];
	$mxnickname = $_COOKIE['nickname'];
}
$nowdate=date("Y-m-d");
$adate=date('Y-m-d',strtotime("$nowdate -7 day"));
if ($mxuserid==""){
	echo "|@#page#@|";
	exit();
}
$pagesize=intval($pagesize);
if ($pagesize==0){$pagesize=2;}

	if(empty($pageindex)){$pageindex=1;}
    $str=" and userid=$mxuserid and isshowjp='1' ";
    $s="";
	if ($lingid!=""){
		$isuse=intval($lingid);
		$str.=" and lingid='$lingid' ";
		$s.="lingid=$lingid&";
	}
	

	$table=" mx_vpp_lingqu_cp ";
	$order=" order by  createdate desc, id desc";
	$column=" * ";
	$biaoid="id";

	$c=$db->listcount($table,$str);

	$list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);

	if(!is_array($list) or $c==0 and $pageindex==1){
	  echo "|@#page#@|<center>暂无信息</center>";
	  exit();
	}
	else{
		$nowhavenum=($pagesize*($pageindex-1))+count($list);
		if ($nowhavenum<$c){echo "1";}
		echo "|@#page#@|";
		for($i=0;$i<count($list);$i++){
		$thisindex=($pageindex-1)*$pagesize+$i+1
		?>
		<li>
		<h1><?php
		if ( $list[$i]["type"]==2){echo '<span class="yellow">[抽奖]</span>';}
		elseif ( $list[$i]["type"]==3){echo '<span class="yellow">[刮刮乐]</span>';}
		else{echo '<span class="yellow">[大转盘]</span>';}
		echo $list[$i]["cptitle"];
		?></h1>
		<h2><?php echo $list[$i]["jxtitle"];
		if ( $list[$i]["isling"]==1){echo '<span class="red">[已领取]</span>';}?></h2>
		<h2><b>编号：</b><?php echo $list[$i]["cpcode"]?></h2>
		<h2><b>中奖时间：</b><?php echo $list[$i]["createdate"]?></h2>
		<?php if ( $list[$i]["isling"]==1){?>
		<h2><b>领取时间：</b><?php echo $list[$i]["lingdate"]?></h2>
		<?php }?>
		<div class="clear"></div></li>
		<div class="clear"></div>
	<?php
		}
	}
?>